package com.zhuss.controller.food;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.zhuss.bean.bo.food.order.DetailOrderBo;
import com.zhuss.bean.bo.food.order.SearchOrderBo;
import com.zhuss.bean.vo.food.order.ListOrderVo;
import com.zhuss.common.BaseController;
import com.zhuss.common.PageVo;
import com.zhuss.common.ReadService;
import com.zhuss.exception.WpsException;
import com.zhuss.food.order.OrderReadServiceExt;
import com.zhuss.food.processor.OrderExport;


/**
 * 订单查询 controller
 * @Author zhushanshuo
   @Date 2020/03/17 16:01
 *
 */
  
 
@RestController
@RequestMapping("/order")
public class OrderReadController extends BaseController {
	
	@Autowired
	@Qualifier("orderReadService")
	private ReadService<Object, Object> orderReadService;
	
	@Autowired
	@Qualifier("orderReadServiceExt")
	private OrderReadServiceExt orderReadServiceExt;
	
	@Autowired
	private OrderExport orderExport;
	
	/**
	 * 详情
	 * @param bo
	 * @return
	 * @throws WpsException
	 */
	@ResponseBody
	@RequestMapping("/detail")
    public Object detail(@RequestBody DetailOrderBo bo) throws WpsException {
		
		Object result = orderReadService.detail(bo);
		return result;
    }
	
	/**
	 * 列表
	 * @param bo
	 * @return
	 * @throws WpsException
	 */
	@ResponseBody
    @RequestMapping("/list")
    public Object list(@RequestBody SearchOrderBo bo) throws WpsException {
		
		Object result = orderReadService.list(bo);
		return result;
    }
	
	/**
	 * box 列表
	 * @param bo
	 * @return
	 * @throws WpsException
	 */
	@ResponseBody
    @RequestMapping("/boxList")
    public Object boxList(@RequestBody SearchOrderBo bo) throws WpsException {
		
		Object result = orderReadServiceExt.boxList(bo);
		return result;
    }
	
	/**
	 * 点炒服务 列表
	 * @param bo
	 * @return
	 * @throws WpsException
	 */
	@ResponseBody
    @RequestMapping("/stirfryList")
    public Object stirfryList(@RequestBody SearchOrderBo bo) throws WpsException {
		
		Object result = orderReadServiceExt.stirfryList(bo);
		return result;
    }
	
	/**
	 * 外卖打包 列表
	 * @param bo
	 * @return
	 * @throws WpsException
	 */
	@ResponseBody
    @RequestMapping("/takeoutList")
    public Object takeoutList(@RequestBody SearchOrderBo bo) throws WpsException {
		
		Object result = orderReadServiceExt.takeoutList(bo);
		return result;
    }
	
	@ResponseBody
	@RequestMapping(value="/exportOrder")
	@SuppressWarnings("unchecked")
    public Object exportOrder(@RequestBody SearchOrderBo bo) throws WpsException {
    	PageVo<ListOrderVo> pageVo = (PageVo<ListOrderVo>) list(bo);
		return orderExport.process(pageVo.getItems());
    }
}
